//
//  BaseXMLParser.h
//  airfight
//
//  Created by aaron more on 12-8-23.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#ifndef airfight_BaseXMLParser_h
#define airfight_BaseXMLParser_h

#include "cocos2d.h"

USING_NS_CC;

class BaseXMLParser : public CCObject, public CCSAXDelegator
{
public:
    virtual bool initWithXMLFile(const char *xmlFile);
    virtual bool parseXMLFile(const char *xmlFilename);
    
    
    // implement pure virtual methods of CCSAXDelegator
    virtual void startElement(void *ctx, const char *name, const char **atts) = 0;
    virtual void endElement(void *ctx, const char *name) = 0;
    virtual void textHandler(void *ctx, const char *ch, int len) = 0;
protected:
    virtual void internalInit(const char* tmxFileName) = 0;
    
protected:
     std::string m_sXMLFileName;
};

static const char* valueForKey(const char *key, std::map<std::string, std::string>* dict)
{
    if (dict)
    {
        std::map<std::string, std::string>::iterator it = dict->find(key);
        return it!=dict->end() ? it->second.c_str() : "";
    }
    return "";
}


#endif
